 package sza.oracle.apps.ap.oie.webui;
 
 import com.sun.java.util.collections.HashMap;
 import java.io.Serializable;
 import java.sql.CallableStatement;
 import java.sql.SQLException;
 import oracle.apps.ap.oie.webui.NavigationUtility;
 import oracle.apps.fnd.common.VersionInfo;
 import oracle.apps.fnd.framework.OAApplicationModule;
 import oracle.apps.fnd.framework.OAException;
 import oracle.apps.fnd.framework.OAViewObject;
 import oracle.apps.fnd.framework.server.OADBTransaction;
 import oracle.apps.fnd.framework.webui.OAControllerImpl;
 import oracle.apps.fnd.framework.webui.OAPageContext;
 import oracle.apps.fnd.framework.webui.beans.OAWebBean;
 import sza.oracle.apps.ap.oie.server.ExpenseTypeHierarchyVOImpl;
 import sza.oracle.apps.ap.oie.utility.SzaOIEUtil;
 
 public class ExpenseTypeTreeCO extends OAControllerImpl
 {
   public static final String RCS_ID = "$Header$";
   public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion("$Header$", "%packagename%");
 
   public void processRequest(OAPageContext pageContext, OAWebBean webBean)
   {
     if (!pageContext.isFormSubmission())
     {
       OAWebBean treeRN = webBean.findIndexedChildRecursive("TreeRN");
       if (treeRN != null)
       {
         treeRN.setRendered(true);
 
         initPage(pageContext, webBean);
       }
     }
   }
 
   public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
   {
     super.processFormRequest(pageContext, webBean);
     processTreeNodePost(pageContext, webBean);
   }
 
   private void processTreeNodePost(OAPageContext pageContext, OAWebBean webBean)
   {
     if ("LinkExpenseTypeTree".equals(pageContext.getParameter("event")))
     {
      
       String SelectedTreeNodeValue = null;
       SelectedTreeNodeValue = pageContext.getParameter("SelectedTreeNodeValue");
       HashMap hashmap = new HashMap();
       hashmap.put("SelectedTreeNodeValue", NavigationUtility.encrypt(pageContext, SelectedTreeNodeValue));
       StringBuffer localStringBuffer = new StringBuffer();
        localStringBuffer.append("OA.jsp?page=");
        localStringBuffer.append("/sza/oracle/apps/ap/oie/poimport/webui/PoImportPG");
        pageContext.forwardImmediately(localStringBuffer.toString(), "OIEENTRYFLOW", (byte)0, null, hashmap, true, "N");
    }
 
    
    
   }
 
   private void initPage(OAPageContext pageContext, OAWebBean webBean)
   {
     String LogMessage = "";
     String LogFunction = "";
     LogFunction = "ExpenseTypeTreeCO.initPage";
 
     LogMessage = "SZA ExpenseTypeTreeCO.initPage - Start";
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     String IsExpenseRecognitionReport = (String)pageContext.getTransactionValue("IsExpenseRecognitionReport");
 
     OAApplicationModule am = pageContext.getApplicationModule(webBean);
     OADBTransaction oadbtransaction = am.getOADBTransaction();
 
     String $$FWK_MultiOrgCurrentOrgId = (String)pageContext.getParameter("$$FWK_MultiOrgCurrentOrgId");
    
     LogMessage = "SZA ExpenseTypeTreeCO processRequest - $$FWK_MultiOrgCurrentOrgId:" + $$FWK_MultiOrgCurrentOrgId;
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     String TemplateId = (String)pageContext.getParameter("TemplateId");
 
     LogMessage = "SZA ExpenseTypeTreeCO processRequest - TemplateId:" + TemplateId.toString();
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     String EmployeeId = (String)pageContext.getParameter("EmployeeId");
 
     LogMessage = "SZA ExpenseTypeTreeCO processRequest - EmployeeId :" + EmployeeId.toString();
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     String CompanyCode = SzaOIEUtil.getEmployeeCompanyCode(pageContext, webBean, EmployeeId);
 
     LogMessage = "SZA ExpenseTypeTreeCO processRequest - CompanyCode:" + CompanyCode.toString();
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     String DefaultCostCenter = (String)pageContext.getParameter("DefaultCostCenter");
 
     LogMessage = "SZA ExpenseTypeTreeCO processRequest - DefaultCostCenter:" + DefaultCostCenter.toString();
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     String FlexConcatenated = "";
     String BudgetCostCenterCode = "";
 
     OAViewObject HeaderVo = (OAViewObject)am.findViewObject("ExpenseReportHeadersVO");
 
    
     LogMessage = "SZA ExpenseTypeTreeCO processRequest - BudgetCostCenterCode:" + BudgetCostCenterCode;
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     if ((BudgetCostCenterCode != null) && (BudgetCostCenterCode != ""))
     {
       FlexConcatenated = BudgetCostCenterCode;
     }
 
     if ("Y".equalsIgnoreCase(IsExpenseRecognitionReport))
     {
       FlexConcatenated = "";
     }
     FlexConcatenated = DefaultCostCenter;
     LogMessage = "SZA ExpenseTypeTreeCO - initPage - Expense Report Template Additional - End";
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     LogMessage = "SZA ExpenseTypeTreeCO processRequest - BudgetCostCenterCode:" + BudgetCostCenterCode;
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     super.processRequest(pageContext, webBean);
 
     LogMessage = "Expense Type AM Name is =>" + am.getFullName();
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     ExpenseTypeHierarchyVOImpl vo = (ExpenseTypeHierarchyVOImpl)am.findViewObject("ExpenseTypeHierarchyVO1");
 
     if (vo == null)
     {
       vo = (ExpenseTypeHierarchyVOImpl)am.createViewObject("ExpenseTypeHierarchyVO1", "sza.oracle.apps.ap.oie.server.ExpenseTypeHierarchyVO");
     }
 
     if (vo != null)
     {
       vo.clearCache();
       vo.refreshWhereClauseParams();
 
       String strSql = "{call ";
       strSql = strSql + " sza_oie_exp_type_tree_pkg.SET_SEGMENT1(:1); ";
       strSql = strSql + " sza_oie_exp_type_tree_pkg.SET_SEGMENT2(:2); ";
       strSql = strSql + " sza_oie_exp_type_tree_pkg.SET_SEGMENT3(:3); ";
       strSql = strSql + " sza_oie_exp_type_tree_pkg.SET_SEGMENT4(:4); ";
       strSql = strSql + " sza_oie_exp_type_tree_pkg.SET_SEGMENT5(:5); ";
       strSql = strSql + " sza_oie_exp_type_tree_pkg.SET_SEGMENT6(:6);  ";
       strSql = strSql + " sza_oie_exp_type_tree_pkg.SET_SEGMENT7(:7); ";
       strSql = strSql + " sza_oie_exp_type_tree_pkg.SET_SEGMENT8(:8); ";
       strSql = strSql + " sza_oie_exp_type_tree_pkg.SET_SEGMENT9(:9); ";
       strSql = strSql + " sza_oie_exp_type_tree_pkg.SET_SEGMENT10(:10); ";
       strSql = strSql + " sza_oie_exp_type_tree_pkg.SET_SEGMENT11(:11); ";
       strSql = strSql + " sza_oie_exp_type_tree_pkg.SET_SEGMENT12(:12);  ";
       strSql = strSql + " sza_oie_exp_type_tree_pkg.SET_SEGMENT13(:13); ";
       strSql = strSql + " sza_oie_exp_type_tree_pkg.SET_SEGMENT14(:14); ";
       strSql = strSql + " sza_oie_exp_type_tree_pkg.SET_SEGMENT15(:15)  ";
 
       strSql = strSql + " } ";
       CallableStatement callablestatement = oadbtransaction.createCallableStatement(strSql, 1);
 
       LogMessage = "SZA ExpenseTypeTreeCO processRequest - $$FWK_MultiOrgCurrentOrgId:" + $$FWK_MultiOrgCurrentOrgId.toString();
 
       SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
       LogMessage = "SZA ExpenseTypeTreeCO processRequest - TemplateId:" + TemplateId.toString();
 
       SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
       LogMessage = "SZA ExpenseTypeTreeCO processRequest - CompanyCode:" + CompanyCode.toString();
 
       SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
       LogMessage = "SZA ExpenseTypeTreeCO processRequest - DefaultCostCenter:" + DefaultCostCenter.toString();
 
       SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
       LogMessage = "SZA ExpenseTypeTreeCO processRequest - FlexConcatenated:" + FlexConcatenated;
 
       SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
       try
       {
         callablestatement.setString(1, $$FWK_MultiOrgCurrentOrgId);
 
         callablestatement.setString(2, TemplateId);
 
         callablestatement.setString(3, CompanyCode);
 
         callablestatement.setString(4, FlexConcatenated);
 
         callablestatement.setString(5, "");
 
         callablestatement.setString(6, "");
 
         callablestatement.setString(7, "");
 
         callablestatement.setString(8, "");
 
         callablestatement.setString(9, "");
 
         callablestatement.setString(10, "");
 
         callablestatement.setString(11, "");
 
         callablestatement.setString(12, "");
 
         callablestatement.setString(13, "");
 
         callablestatement.setString(14, "");
 
         callablestatement.setString(15, "");
 
         callablestatement.execute();
       }
       catch (SQLException sqlexception)
       {
         oadbtransaction.rollback();
         throw OAException.wrapperException(sqlexception);
       }
       finally
       {
         try
         {
           callablestatement.close();
         }
         catch (Exception localException1)
         {
           throw OAException.wrapperException(localException1);
         }
       }
       oadbtransaction.commit();
 
       String WhereClause = " 1 = 1 ";
       WhereClause = WhereClause + " AND TRIM(tree_node_code_p) = '0' ";
 
       LogMessage = "SZA Tree VO WhereClause:" + vo.getQuery();
 
       SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
       vo.setWhereClause(WhereClause);
       vo.setWhereClauseParams(null);
       vo.executeQuery();
     }
     LogMessage = "SZA ExpenseTypeTreeCO.initPage - End";
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
   }
 
   private void processRequestPageButtons(OAPageContext pageContext, OAWebBean webBean)
   {
     String LogMessage = "";
     String LogFunction = "";
     LogFunction = "ExpenseTypeTreeCO.processRequestPageButtons";
 
     LogMessage = "SZA ExpenseTypeTreeCO.processRequestPageButtons - Start";
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     SzaOIEUtil.printContextParameter(pageContext, webBean);
 
     SzaOIEUtil.printContextTransaction(pageContext, webBean);
 
     if ("ReturnButton".equals(pageContext.getParameter("event")))
     {
       System.out.println("2RBExpenseTypeTree");
 
       String SzaReportLineId = pageContext.getTransactionValue("SzaReportLineId").toString();
 
       String ReportHeaderId = (String)pageContext.getTransactionValue("ReportHeaderId");
 
       Serializable[] aserializable7 = { Boolean.FALSE, SzaReportLineId };
 
       Class[] aclass4 = { Boolean.class, String.class };
 
       HashMap hashmap = new HashMap();
       hashmap.put("SDP_RHID", NavigationUtility.encrypt(pageContext, ReportHeaderId));
 
       hashmap.put("SDP_RLID", NavigationUtility.encrypt(pageContext, SzaReportLineId));
 
       hashmap.put("SDP_EXP_CLASS", "SDP_EXP_CLASS_CASH");
 
       hashmap.put("SDP_UPDATE_MODE", "UPDATE");
 
       hashmap.put("SDP_CALLING_MODULE", "SZA_CASH_ET");
 
       if (pageContext.isLoggingEnabled(2)) {
         pageContext.writeDiagnostics("NavigationUtility.forwardToPage", "ExpenseTypeTreePG", 2);
       }
 
       NavigationUtility.forwardToPage(pageContext, "CashAndOtherLinesPG", hashmap);
     }
 
     LogMessage = "SZA ExpenseTypeTreeCO.processRequestPageButtons - End";
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
   }
 }



